// pages/my/level/level.js
Page({
  data: {
    userInfo: {},
    levelInfo: {},
    vipSwiperIndex: 0,
    levelList: [{
        level: 1,
        title: "小白玩家"
      },
      {
        level: 2,
        title: "青铜玩家"
      },
      {
        level: 3,
        title: "白银玩家"
      },
      {
        level: 4,
        title: "黄金玩家"
      },
      {
        level: 5,
        title: "钻石玩家"
      },
      {
        level: 6,
        title: "大神玩家"
      },
      {
        level: 7,
        title: "荣耀玩家"
      },
    ],
    vipList: [{
        name: "日接单量递增",
        viptext: "VIP解锁",
        icon: "https://www.linxiaobang.com.cn/miniprogram/image/ico_prerogative_1@2x.png"
      },
      {
        name: "1元抽奖特权",
        viptext: "VIP解锁",
        icon: "https://www.linxiaobang.com.cn/miniprogram/image/ico_prerogative_2@2x.png"
      },
      {
        name: "积分兑换特权",
        viptext: "V2解锁",
        icon: "https://www.linxiaobang.com.cn/miniprogram/image/ico_prerogative_3@2x.png"
      },
      {
        name: "专属客服",
        viptext: "V3解锁",
        icon: "https://www.linxiaobang.com.cn/miniprogram/image/ico_prerogative_4@2x.png"
      },
      {
        name: "高价单优先推",
        viptext: "V4解锁",
        icon: "https://www.linxiaobang.com.cn/miniprogram/image/ico_prerogative_5@2x.png"
      },
      {
        name: "专属派单",
        viptext: "V4解锁",
        icon: "https://www.linxiaobang.com.cn/miniprogram/image/ico_prerogative_6@2x.png"
      },
      {
        name: "争议先赔付",
        viptext: "V5解锁",
        icon: "https://www.linxiaobang.com.cn/miniprogram/image/ico_prerogative_7@2x.png"
      },
      {
        name: "提现更快",
        viptext: "V6解锁",
        icon: "https://www.linxiaobang.com.cn/miniprogram/image/ico_prerogative_8@2x.png"
      },
      {
        name: "提现门槛更低",
        viptext: "V7解锁",
        icon: "https://www.linxiaobang.com.cn/miniprogram/image/ico_prerogative_9@2x.png"
      }
    ],
    payList: [{
        level: 2,
        name: "V2玩家",
        value: "19.9"
      },
      {
        level: 3,
        name: "V3玩家",
        value: "29.9"
      },
      {
        level: 4,
        name: "V4玩家",
        value: "39.9"
      },
      {
        level: 5,
        name: "V5玩家",
        value: "49.9"
      },
      {
        level: 6,
        name: "V6玩家",
        value: "59.9"
      },
      {
        level: 7,
        name: "V7玩家",
        value: "69.9"
      },
    ],
    code: "",
    popup_show: false
  },
  onLoad: function (options) {},
  onShow: function () {
    getApp().globalData.http.userLevel().then(res => {
      let vipSwiperIndex = null;
      if (res.data.level <= 5) {
        vipSwiperIndex = 0;
      } else {
        vipSwiperIndex = 1;
      }
      this.setData({
        vipSwiperIndex: vipSwiperIndex,
        levelInfo: res.data
      });
    });
    this.setData({
      userInfo: wx.getStorageSync("userInfo")
    });
  },
  onShareAppMessage() {},
  navTo(e) {
    wx.navigateTo({
      url: e.currentTarget.dataset.path,
    });
  },
  toDes() {
    wx.navigateTo({
      url: "/pages/my/privilegedetails/privilegedetails",
    })
  },
  openPopup() {
    getApp().globalData.http.getInviteCode().then(res => {
      this.setData({
        code: res.data.code,
        popup_show: true
      });
    });
  },
  codeConfirm() {
    wx.setClipboardData({
      data: this.data.code,
      success(res) {
        wx.getClipboardData({
          success(res) {}
        })
      }
    });
  },
  upvip() {
    wx.pageScrollTo({
      selector: "#vip",
      duration: 300
    })
  }
})